﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Beacon.SPC
{
    /// <summary>
    /// SPC chart type
    /// reference URL http://en.wikipedia.org/wiki/Control_chart
    /// 
    /// XbarR   AVERAGES AND RANGE CHARTS
    /// XbarS   AVERAGES AND STDEV CHARTS
    /// XMR     Shewhart individuals control chart
    /// C       Count Charts
    /// U       Unit Charts
    /// P       Proportion Charts 
    /// NP      Number of Proportion Charts
    /// </summary>
    public enum SpcChartType { XBarR, XBarS, XMR, C, U, P, NP };
    
    /// <summary>
    /// Spc data type for calculate sigma
    /// </summary>
    public enum SpcDataType { Mean, Range, Std };


    /// <summary>
    /// Western Electric rules
    /// </summary>
    public enum SpcRules
    {
        WERule1,        // Any single data point falls outside the 3σ limit from the centerline.

        WERule2,        // 2 out of 3 consecutive points fall beyond the 2σ limit (in zone A or beyond),
        // on the same side of the centerline.

        WERule3,        // 4 out of 5 consecutive points fall beyond the 1σ limit (in zone B or beyond), 
        // on the same side of the centerline.

        WERule4,        // 9 consecutive points fall on the same side of the centerline (in zone C or beyond).

        Trend,          // 7 or more consecutive points without a change in direction.

        Oscillation,    // 14 or more consecutive points alternate in direction.

        Stratification, // 15 or more consecutive points fall inside 1σ zone.

        Mixture         // 8 or more consecutive points fall outside 1σ zone and on both sides.
    };

    /// <summary>
    /// inditify the side 
    /// </summary>
    public enum SpcControlSide { Upper, Lower, Both }

    /// <summary>
    /// way to discribe a rule
    /// </summary>
    public class SpcRuleDefinition
    {
        public SpcRules Type { get; set; }
        public SpcControlSide Side { get; set; }
        public SpcRuleDefinition(SpcRules type, SpcControlSide side)
        {
            Type = type;
            Side = side;
        }
    }


    // i'd like to add a spc chart class for help the relationship bewteen chart type and control limit.
    // i'm not sure if it is a good idea.
}
